<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/normalize.css">
    <link rel="stylesheet" href="./js/flexible.js">
    <style>
        .box {
            position: relative;
            width: 100%;
            height: 53.333333rem;
            background-color: cornflowerblue;
        }

        .bottle {
            position: absolute;
            width: 1.333333rem;
            height: 1.333333rem;
            background-color: cadetblue;
        }
    </style>
</head>

<body>
    <div class="box">

    </div>
    <script>
        let box = document.querySelector('.box');
        box.addEventListener('click', function (e) {

            let x = e.pageX;
            let y = e.pageY;
            console.log(x + '和' + y);
            let bottle = document.createElement('div');
            bottle.className = 'bottle';
            bottle.style.width = '100px';
            bottle.style.height = '100px';
            bottle.style.backgroundColor = 'lightgreen';
            bottle.style.left = (x - 50) + 'px';
            bottle.style.top = (y - 50) + 'px';
            box.appendChild(bottle);
            box.removeChild(box.childNodes[0]);

            let timer = setInterval(function () {

                bottle.style.left = x + 'px';
                bottle.style.top = y + 'px';
            }, 10)

        })


    </script>
</body>

</html>